package com.zhong.gang.applib.utils;

import android.view.View;
import android.view.animation.Animation;
import android.view.animation.CycleInterpolator;
import android.view.animation.TranslateAnimation;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by ajin on 2018/3/15.
 */

public class CheckedUtils {


    private static boolean isMobileNo(String var1) {
        if (var1 == null)
            return false;
        if (var1.length() != 11) {
            return false;
        } else {
            boolean var2 = false;

            try {
                Pattern var3 = Pattern.compile("^((16[0-9])|(14[7-9])|(13[0-9])|(19[0-9])|(15[^4,\\D])|(17[0-9])|(18[0-9]))\\d{8}$");
                Matcher var4 = var3.matcher(var1);
                var2 = var4.matches();
            } catch (Exception var5) {
                var5.printStackTrace();
            }
            return var2;
        }
    }

    /**
     * 是否是手机号
     * @param phone
     * @return
     */
    public static boolean isPhone(String phone) {
        if (phone ==null)
            return false;
        if (phone.length() == 0) {
            return false;
        } else if (!isMobileNo(phone)) {
            return false;
        }
        return true;
    }

    public static boolean isRulePass(String pass) {
        if (pass == null)
            return false;
        else if (pass.length() < 6) {
            return false;
        } else if (pass.length() > 10) {
            return false;
        }
        return true;
    }

    /**
     * 判断字符串是否相同
     * @param pass
     * @param Nextpass
     * @return
     */
    public static boolean isSome(String pass, String Nextpass) {
        if (pass == null)
            return false;
        if (Nextpass == null)
            return false;
        if (!pass.equals(Nextpass)) {
            return false;
        }
        return true;
    }

    /**
     * 判断是否是空
     * @param str
     * @return
     */
    public static boolean isEmtry(String str){
        if (str == null)
            return true;
        else if (str.equals(""))
            return true;
        else if (str.equals("null"))
            return true;
        else return false;
    }


    public static boolean isCardNumber(String cardnumber){
        return IDCardUtil.IDCardValidate(cardnumber);
    }

    public static Animation shakeAnimation(View view, int counts) {
        Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
        translateAnimation.setInterpolator(new CycleInterpolator(counts));
        translateAnimation.setDuration(500);
        view.startAnimation(translateAnimation);
        return translateAnimation;
    }


}
